//
//  DelegateViewController.swift
//  Swift各种传值
//
//  Created by Bao on 15/12/10.
//  Copyright © 2015年 Microlink. All rights reserved.
//

import UIKit

protocol chagngeTitleDelegate:NSObjectProtocol
{
    func changeNavTitle(string:String)

}

class DelegateViewController: UIViewController {

    var delegate:chagngeTitleDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.whiteColor()
        self.title = "代理传值"
        
        let btn:UIButton? = UIButton(type: .Custom)
        btn?.frame = CGRectMake(60, 70, 100, 50)
        btn?.backgroundColor = UIColor.redColor()
        btn?.setTitle("改变title", forState:.Normal)
        btn?.addTarget(self, action: Selector("greetings"), forControlEvents: .TouchUpInside)
        self.view .addSubview(btn!)
        
        
        // Do any additional setup after loading the view.
    }
    func greetings(){
        if((self.delegate) != nil){
            self.delegate?.changeNavTitle("代理传的值")
        }
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
